
import asyncio
from concurrent.futures import ThreadPoolExecutor

executor = ThreadPoolExecutor(max_workers=4)

# --------------------------
# 工具函数
# --------------------------
async def run_in_thread(func, *args):
    loop = asyncio.get_event_loop()
    return await loop.run_in_executor(executor, func, *args)


# 审计日志装饰器
def audit_action(action: str):
    def decorator(func):
        setattr(func, "__audit_action__", action)
        return func
    return decorator